home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE15 / CPPCLASS / cpp1632 / CPPDLL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-17  |  1.2 KB  |  55 lines

  1. #include <windows.h>
  2. #include <dos.h>
  3. #include <stdio.h>
  4. #include "delevent.h"
  5.  
  6. #if !defined(__FLAT__)
  7.   #pragma options -WD -xc//makes all functions in a DLL exportable
  8.   //#pragma option -xc //Safe exceptions
  9.   #define FARVTABLE _huge
  10. #else
  11.   #define FARVTABLE
  12. #endif
  13.  
  14. //we use huge so that we can have far vtbls and not export the whole class
  15. class FARVTABLE TDLLClass{
  16.   char Buffer[80];
  17.   int InternalValue;
  18.   TEvent FEvent;
  19.  
  20.   virtual void  SetValue(int Info){InternalValue = Info;}
  21.   virtual int   GetValue(){return InternalValue;}
  22.   virtual void  SetEvent(TEvent func){FEvent = func;};
  23.  
  24.  
  25. public:
  26.   TDLLClass():InternalValue(0){FEvent.Code = NULL;};
  27.  
  28.   virtual void  ShowThevalue()
  29.   {
  30.      wsprintf(Buffer, "The value %d\nCOM to da Max!!!!",InternalValue);
  31.      MessageBox(NULL,Buffer,"From The C++ DLL",MB_OK);
  32.   }
  33.  
  34.   virtual void  DoEvent()
  35.   {
  36.       if (FEvent.Code != NULL)
  37.          ((TNotifyEvent)FEvent.Code)(FEvent.Self,(const void *)this);
  38.   }
  39. };
  40.  
  41. extern "C" {
  42.  
  43. TDLLClass*  _export _cdecl CONSTRUCTCLASS()
  44. {
  45.   return new TDLLClass;
  46. };
  47.  
  48. void  _export _cdecl DESTRUCTCLASS(TDLLClass *DLLClass)
  49. {
  50.   if (DLLClass != NULL)
  51.          delete DLLClass;
  52. };
  53. }
  54.  
  55.